import { createApp } from 'vue'
import App from './App.vue'
import { createPinia } from 'pinia'
import router from './router'
import ElementPlus from 'element-plus'
import 'element-plus/dist/index.css'
import Table from '@/components/Table/Table.vue'
import Dialog from '@/components/Dialog/Dialog.vue'

import { userPlugins } from '@/store/plugins/user'

const app = createApp(App)

// 声明自定义全局属性，防止报错
declare module '@vue/runtime-core' {
  export interface ComponentCustomProperties {
    myname: string
  }
}
// 定义全局属性
app.config.globalProperties.myname = '哈哈哈'

// 在script标签里面使用
// import { getCurrentInstance } from 'vue';
// const instance = getCurrentInstance()
// console.log(instance?.proxy?.myname)

// 在模板里使用
// <div>
//   {{myname}}
// </div>

const store = createPinia()
store.use(userPlugins)

app.use(store)
app.use(router)
app.use(ElementPlus)
app.component('me-table', Table)
app.component('me-dialog', Dialog)

app.mount('#app')
